package ${package}.${rootArtifactId}.controller.account;

import ${package}.${rootArtifactId}.common.model.PageInfoResult;
import ${package}.${rootArtifactId}.common.model.Result;
import ${package}.${rootArtifactId}.model.param.account.AccountOpParam;
import ${package}.${rootArtifactId}.model.param.account.AccountQueryParam;
import ${package}.${rootArtifactId}.model.po.account.AccountPO;
import ${package}.${rootArtifactId}.service.account.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author weidong.lin
 * @description 账号信息表 ctrl
 * @date 2021-07-20 18:09:29
 */
@Controller
@RequestMapping("/wapi/account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    @PostMapping("/getPages")
    @ResponseBody
    public Result<PageInfoResult<AccountPO>> getPages(@RequestBody AccountQueryParam param) {
        return Result.success(accountService.getPages(param));
    }

    @PostMapping("/create")
    @ResponseBody
    public Result create(@RequestBody AccountOpParam opParam) {
        return accountService.create(opParam);
    }

    @PostMapping("/update")
    @ResponseBody
    public Result update(@RequestBody AccountOpParam opParam) {
        return accountService.update(opParam);
    }

    @PostMapping("/delete/{id}")
    @ResponseBody
    public Result delete(@PathVariable Long id) {
        return accountService.delete(id);
    }

    @RequestMapping(value = "/getById/{id}", method = RequestMethod.GET)
    @ResponseBody
    public Result<AccountPO> getById(@PathVariable Long id) {
        return Result.success(accountService.getById(id));
    }
}
